﻿using System;
using System.Collections.Generic;
using System.Linq;
using DocProcessingWorkflow.Helpers;
using Entities.File;
using FluentAssertions;
using NUnit.Framework;

namespace WebTests.Helpers
{
    [Category("Unit")]
    [TestFixture]
    public class HtmlExtensionsTests
    {
        [Test]
        public void GetListItemsForFiles_WhenCalled_ReturnsCorrectNumberofListItemObjects()
        {
            //Arrange

            var fileInfoList = new List<FileInfo>()
            {
                new FileInfo(){Name = "testfilename-1",FileCreationDate = DateTime.Now},
                new FileInfo(){Name = "testfilename-2",FileCreationDate = DateTime.Now},
                new FileInfo(){Name = "testfilename-3",FileCreationDate = DateTime.Now},
                new FileInfo(){Name = "testfilename-5",FileCreationDate = DateTime.Now},
            };


            //Act

            var selectListItems = HtmlExtensions.GetListItemsForFiles(fileInfoList);

            //Assert

            selectListItems.Count().ShouldBeEquivalentTo(fileInfoList.Count);

        }

        [Test]
        public void GetListItemsForFiles_WhenCalled_TextIsInCorrectFormat()
        {
            //Arrange

            var fileInfoList = new List<FileInfo>()
            {
                new FileInfo(){Name = "testfilename-1",FileCreationDate = new DateTime(2009,6,15,13,45,30)},
            };

            const string expectedText = "testfilename-1(Date : 15/06/2009 13:45:30)";

            //Act

            var selectListItems = HtmlExtensions.GetListItemsForFiles(fileInfoList);

            //Assert

            selectListItems.First().Text.ShouldBeEquivalentTo(expectedText);

        }


    }
}